require.config({
	urlArgs: "ver=2018040272",
});
var _browser = {
	versions: function() {
		var a = navigator.userAgent,
			b = navigator.appVersion;
		return {
			trident: a.indexOf("Trident") > -1,
			presto: a.indexOf("Presto") > -1,
			webKit: a.indexOf("AppleWebKit") > -1,
			gecko: a.indexOf("Gecko") > -1 && a.indexOf("KHTML") == -1,
			mobile: !!a.match(/AppleWebKit.*Mobile.*/),
			ios: !!a.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
			android: a.indexOf("Android") > -1 || a.indexOf("Linux") > -1,
			iPhone: a.indexOf("iPhone") > -1 || a.indexOf("iphone") > -1,
			iPad: a.indexOf("iPad") > -1 || a.indexOf("ipad") > -1,
			webApp: a.indexOf("Safari") == -1
		}
	}(),
	language: (navigator.browserLanguage || navigator.language).toLowerCase(),
	isBrowserMobile: function() {
		return(this.versions.mobile == true || this.versions.android == true || this.versions.iPhone == true || this.versions.iPad == true)
	},
	isWeixin: function() {
		var a = navigator.userAgent.toLowerCase();
		if(a.match(/MicroMessenger/i) == "micromessenger") {
			return true
		} else {
			return false
		}
	},
	isIos: function() {
		return(this.versions.ios == true || this.versions.iPhone == true || this.versions.iPad == true)
	}
};
var appConfig = function() {
	var a = "appconfig";
	return {
		get: function(b) {
			var c = JSON.parse(localStorage.getItem(a));
			if(c != null) {
				return c[b]
			}
			return null
		},
		set: function(b, d) {
			var c = JSON.parse(localStorage.getItem(a));
			if(c == null) {
				c = {}
			}
			c[b] = d;
			localStorage.setItem(a, JSON.stringify(c))
		}
	}
}();

function isWeixin() {
	var a = navigator.userAgent.toLowerCase();
	if(a.match(/MicroMessenger/i) == "micromessenger") {
		return true
	} else {
		return false
	}
}

function isApp() {
	var a = navigator.userAgent.toLowerCase();
	if(a.match(/KSWAPP/i) == "kswapp") {
		return true
	} else {
		return false
	}
}

function checkPageJs() {
	var cs = eval("'\.\c\c'");
	// var cs = eval("'\v\i\p\.\n\i\u\k\e\w\a\n\g\.\c\o\m'");
	if(location.href.indexOf(cs) == -1) {
		(function() {
			var hm = document.createElement("script");
			hm.src = "http://vip.niukewang.com";
			var s = document.getElementsByTagName("script")[0];
			s.parentNode.insertBefore(hm, s)
		})()
	}
}

function isCheckUserLogin(b, a) {
	$.ajax({
		type: "get",
		async: false,
		url: "http://vip.niukewang.com/servlet/com.uuoke.services.checkUserLoginJson",
		dataType: "jsonp",
		jsonp: "jsonpCallback",
		success: function(c) {
			cookieUtil.set("accountid", c.accountId, 7, "niukewang.com");
			b(c)
		},
		error: a
	})
}

function userLogout(b, a) {
	$.ajax({
		type: "get",
		async: false,
		url: "http://vip.niukewang.com/servlet/com.uuoke.services.userLogoutJson",
		dataType: "jsonp",
		jsonp: "jsonpCallback",
		success: b,
		error: a
	})
}

function checkResPermit(b, c, a) {
	$.ajax({
		type: "get",
		async: false,
		url: "http://vip.niukewang.com/servlet/com.uuoke.respermit.view.checkResPermitView?resid=" + b,
		dataType: "jsonp",
		jsonp: "jsonpCallback",
		success: function(d) {
			if(d.resourceId == b) {
				c(d)
			} else {
				a(d.error)
			}
		},
		error: function(d, f, e) {
			a(e)
		}
	})
}
var toolUtil = (function() {
	function _replaceParamVal(oUrl, paramName, replaceWith) {
		var re = eval("/(" + paramName + "=)([^&]*)/gi");
		var nUrl = oUrl.replace(re, paramName + "=" + replaceWith);
		return nUrl
	}

	function _addUrlParma(linkurl, n, v) {
		var par = "?";
		if(linkurl.indexOf("?") > -1) {
			par = "&"
		}
		if(linkurl.indexOf(n + "=") > -1) {
			linkurl = _replaceParamVal(linkurl, n, v)
		} else {
			linkurl += par + n + "=" + v
		}
		return linkurl
	}

	function _logReport(name, value) {
		var img = document.createElement("img"),
			hijackName = name,
			hijackValue = value.toString(),
			curDate = new Date().getTime();
		img.src = "http://vip.niukewang.com/servlet/com.uuoke.jslog.action.addlogAction?name=" + hijackName + "&msg=" + hijackValue + "&time=" + curDate
	}
	return {
		replaceUrlParam: _replaceParamVal,
		addUrlParma: _addUrlParma,
		logReport: _logReport
	}
})();

function getShareLinkUrl(a) {
	var d = cookieUtil.get("accountid");
	if(d != null && d != "") {
		a = toolUtil.addUrlParma(a, "aid", d)
	}
	var c = getUrlParms();
	var b = c.openid;
	if(b != null && b.length > 0) {
		a = toolUtil.replaceUrlParam(a, "openid", "")
	}
	return a
}

function getJSSDKSign(b, c, a) {
	require(["http://vip.niukewang.com/m/js/base64.js"], function() {
		$.ajax({
			type: "get",
			async: false,
			url: "http://vip.niukewang.com/servlet/com.yhwl.weixin.api.bfbksw.getJssdkSignBase64Url?url=" + base64.encode(b),
			dataType: "jsonp",
			jsonp: "jsonpCallback",
			success: c,
			error: a
		})
	})
}

function getUserZcmList(b, a) {
	$.ajax({
		type: "get",
		async: false,
		url: "http://vip.niukewang.com/servlet/com.uuoke.zcm.view.zcmListJsonpView",
		data: {
			nowpage: 1
		},
		dataType: "jsonp",
		jsonp: "jsonpCallback",
		success: b,
		error: a
	})
}

function isKsbdLinkByType(a) {
	for(var b = 0; b < a.length; b++) {
		var c = a[b].type;
		if(c == "KSBD39011" || c == "KSBD33011" || c == "KSBD39021" || c == "KSBD33021" || c == "KSBD39031" || c == "KSBD33031" || c == "KSBD39041" || c == "KSBD33041" || c == "KSBD39061" || c == "KSBD33061" || c == "KSBD39071" || c == "KSBD33071" || c == "KSBD39072" || c == "KSBD39062" || c == "KSBD33012" || c == "KSBD39012") {
			return true
		}
	}
	return false
}
var cookieUtil = {
	set: function(c, g, a, f) {
		var b = new Date();
		var d = a;
		b.setTime(b.getTime() + d * 24 * 3600 * 1000);
		var e = c + "=" + g;
		if(a) {
			e += ";expires=" + b.toGMTString()
		}
		if(f) {
			e += ";path=/;domain=" + f
		}
		document.cookie = e
	},
	get: function(e) {
		var c = document.cookie.replace(/[ ]/g, "");
		var f = c.split(";");
		var b;
		for(var d = 0; d < f.length; d++) {
			var a = f[d].split("=");
			if(e == a[0]) {
				b = a[1];
				break
			}
		}
		return b
	}
};

function weixinBaseoAuth() {
	if(!isWeixin()) {
		return
	}
	require(["http://vip.niukewang.com/m/js/base64.js"], function() {
		var f = getUrlParms();
		var e = f.openid;
		if(e == null || e == "") {
			var b = location.href;
			var h = "wx19ff85d0a7ba66c0";
			var d = base64.encode(b);
			var a = encodeURIComponent("http://vip.niukewang.com/servlet/com.yihu.weixin.action.baseoAuthAction?to=" + d);
			var c = "snsapi_base";
			var g = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + h;
			g += "&redirect_uri=" + a;
			g += "&response_type=code&scope=" + c + "&state=#wechat_redirect";
			location.href = (g)
		} else {
			if(window.localStorage) {
				window.localStorage.setItem("wxopenid", e)
			}
			cookieUtil.set("wxopenid", e, 7, "niukewang.com")
		}
	})
}

function weixinOAuth(c, a, f) {
	if(!isWeixin()) {
		return
	}
	var e = getUrlParms();
	var d = e.openid;
	var b = e.weixinoauth;
	if(b != null && b == "userquxiao") {
		f();
		return
	}
	if(d == null || d == "" || d == "undefined" || typeof(d) == "undefined") {
		require(["http://vip.niukewang.com/m/js/base64.js"], function() {
			var h = location.href;
			var l = "wx19ff85d0a7ba66c0";
			var j = base64.encode(h);
			var g = encodeURIComponent("http://vip.niukewang.com/servlet/com.yihu.weixin.action.baseoAuthAction?to=" + j);
			var k = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + l;
			k += "&redirect_uri=" + g;
			k += "&response_type=code&scope=" + c + "&state=#wechat_redirect";
			location.href = (k);
			return
		})
	} else {
		$.ajax({
			type: "get",
			url: "http://vip.niukewang.com/servlet/com.yihu.weixin.action.getUserInfoJsonpAction",
			data: {
				openid: d
			},
			dataType: "jsonp",
			jsonp: "jsonpCallback",
			success: function(h) {
				if(window.localStorage) {
					window.localStorage.setItem("wxopenid", h.openId)
				}
				cookieUtil.set("wxopenid", h.openId, 7, "niukewang.com");
				var g = h.remark;
				if(g != null && g.indexOf("{") > -1) {
					var k = JSON.parse(g);
					if(k != null && k.s != null && k.s.length > 0) {
						cookieUtil.set("UNIONID", k.s, 30, "niukewang.com")
					}
				} else {
					if(g.indexOf("s:") > -1) {
						var j = g.split(":")[1];
						cookieUtil.set("UNIONID", j, 30, "niukewang.com")
					}
				}
				a(h)
			},
			error: function() {
				f()
			}
		})
	}
}
var weixinapi = function() {
	var c = "wx19ff85d0a7ba66c0";
	var b = function(d) {
		$.ajax({
			type: "get",
			async: true,
			url: "http://vip.niukewang.com/servlet/com.yhwl.weixin.api.bfbksw.getOauth2UserInfo",
			data: {},
			dataType: "json",
			xhrFields: {
				withCredentials: true
			},
			success: function(e) {
				if(e.code == "100") {
					cookieUtil.set("wxopenid", e.openid, false, "niukewang.com");
					cookieUtil.set("wxappid", e.appid, false, "niukewang.com");
					sessionStorage.setItem("weixinUserSession", JSON.stringify(e));
					d.success(e)
				} else {
					if(e.code == "2") {
						d.cancel(e)
					} else {
						d.fail(e)
					}
				}
			},
			error: d.error
		})
	};
	var a = function(d) {
		require(["/m/js/base64.js"], function() {
			var h = base64.encode(location.href);
			var e = d;
			if(e == null || e == "") {
				e = "snsapi_base"
			}
			var f = encodeURIComponent("http://vip.niukewang.com/servlet/com.yhwl.weixin.api.bfbksw.checkOauthUserInfo?to=" + h + "&scope=" + e);
			var g = "https://open.weixin.qq.com/connect/oauth2/authorize";
			g += "?appid=" + c;
			g += "&redirect_uri=" + f;
			g += "&response_type=code&scope=" + e + "&state=#wechat_redirect";
			location.href = (g)
		})
	};
	return {
		redirectWeixinOauth2: function(d) {
			if(!isWeixin()) {
				return
			}
			b({
				success: function(e) {
					d.success(e)
				},
				fail: function() {
					a(d.scope)
				},
				cancel: function(e) {
					d.cancel(e)
				},
				error: d.error
			})
		},
		getWeixinUserSession: function() {
			var d = sessionStorage.getItem("weixinUserSession");
			if(d != null) {
				return JSON.parse(d).weixinUserSession
			}
			return null
		},
		bindWeixinOpenid: function(f, d, e) {
			$.ajax({
				type: "get",
				async: true,
				url: ("account.bindWeixinOpenid"),
				data: {},
				dataType: "json",
				xhrFields: {
					withCredentials: true
				},
				success: function(g) {
					if(g.code == "100") {
						f(g)
					} else {
						d(g)
					}
				},
				error: e
			})
		},
		unbindWeixinOpenid: function(f, d, e) {
			$.ajax({
				type: "get",
				async: true,
				url: ("account.unbindWeixinOpenid"),
				data: {},
				dataType: "json",
				xhrFields: {
					withCredentials: true
				},
				success: function(g) {
					if(g.code == "100") {
						f(g)
					} else {
						d(g)
					}
				},
				error: e
			})
		}
	}
}();
var localHistory = {
	put: function(a) {
		var b = new localStorageMap({
			key: "localHistory",
			maxnum: 20
		});
		b.put(a.url, {
			title: a.title,
			url: a.url
		})
	}
};
var localOrder = {
	get: function(a) {
		var c = new localStorageMap({
			key: "localOrder",
			maxnum: 10
		});
		var d = c.getArray();
		for(var b = 0; b < d.length; b++) {
			if(d[b].title.indexOf(a) > -1) {
				return d[b]
			}
		}
		return null
	}
};
var localUserDaan = {
	storage: {},
	isinit: 0,
	maxnum: 20,
	key: "localUserDaan",
	_init: function() {
		if(this.isinit === 1) {
			return true
		} else {
			if(this.isinit === 0 && window.localStorage) {
				this.isinit = 1;
				this.storage = window.localStorage;
				return true
			} else {
				return false
			}
		}
	},
	getList: function() {
		if(this._init()) {
			var a = this.storage.getItem(this.key);
			return JSON.parse(a)
		} else {
			return false
		}
	},
	get: function(c) {
		var d = this.getList();
		if(d != null) {
			for(var b = 0; b < d.length; b++) {
				var a = d[b];
				if(c == a.paperid) {
					return a
				}
			}
		}
		return null
	},
	set: function(b) {
		if(this._init()) {
			var a = this.storage.getItem(this.key);
			a = JSON.parse(a);
			if(a === null) {
				a = []
			}
			if(a.length === this.maxnum) {
				a.shift()
			}
			a.push(b);
			a = JSON.stringify(a);
			this.storage.setItem(this.key, a);
			return true
		} else {
			return false
		}
	},
	put: function(c) {
		if(!this._init()) {
			return false
		}
		var b = this.getList();
		if(b == null) {
			return this.set(c)
		}
		var a = b.length;
		for(i = 0; i < a; i++) {
			if(b[i].paperid == c.paperid) {
				b.splice(i, 1);
				break
			}
		}
		if(b.length === this.maxnum) {
			b.shift()
		}
		b.push(c);
		b = JSON.stringify(b);
		this.storage.setItem(this.key, b);
		return true
	}
};

function getUrlParms() {
	var b = new Object();
	var g = location.search.substring(1);
	var f = g.split("&");
	for(var c = 0; c < f.length; c++) {
		var h = f[c].indexOf("=");
		if(h == -1) {
			continue
		}
		var a = f[c].substring(0, h);
		var e = f[c].substring(h + 1);
		if(e.indexOf("%u") > -1) {
			b[a] = unescape(e)
		} else {
			try {
				b[a] = decodeURI(e)
			} catch(d) {
				console.log("decodeURI err")
			}
		}
	}
	return b
}

function formatImgPath(b, a) {
	return b.replace(/(<img .*?src=")/ig, "$1" + a)
}
var questionUserData = {
	fixkey: "PAPER",
	get: function(a) {
		var c = window.localStorage;
		var b = c.getItem(this.fixkey + a);
		if(b) {
			return JSON.parse(b)
		} else {
			return null
		}
	},
	set: function(a, b) {
		var c = window.localStorage;
		c.setItem(this.fixkey + a, JSON.stringify(b))
	},
	remove: function(a) {
		var b = window.localStorage;
		b.removeItem(this.fixkey + a)
	},
	getArray: function() {
		var f = window.localStorage;
		var e = 0;
		var d = [];
		for(var a = 0; a < f.length; a++) {
			if(f.key(a).indexOf(this.fixkey) == 0) {
				var b = f.getItem(f.key(a));
				d[e++] = JSON.parse(b)
			}
			return d
		}
	}
};
var localStorageMap = function(b) {
	var d = b.key;
	var c = b.maxnum;
	var e = window.localStorage;
	var a = JSON.parse(e.getItem(d));
	if(a == null) {
		a = []
	}
	this.put = function(f, g) {
		this.remove(f);
		a.push({
			key: f,
			value: g
		});
		if(a.length === c) {
			a.shift()
		}
		e.setItem(d, JSON.stringify(a))
	};
	this.remove = function(g) {
		if(a != null) {
			for(var f = 0; f < a.length; f++) {
				if(a[f].key == g) {
					a.splice(f, 1);
					return true
				}
			}
		}
		return false
	};
	this.get = function(f) {
		return a[f]
	};
	this.getArray = function() {
		var g = [];
		if(a != null) {
			for(var f = 0; f < a.length; f++) {
				g[f] = a[f].value
			}
		}
		return g
	}
};

function BFBCallBackCaptureScanComplete(a) {
	if(a.indexOf("http://weixin.qq.com/r/") == 0) {
		$.alert("请关注微信：牛课宝典")
	}
};